<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('修改客户')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-customer-edit" th:object="${customer}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">客户姓名：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">手机号：</label>
                <div class="col-sm-8">
                    <input name="telephone" th:field="*{telephone}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">详细地址：</label>
                <div class="col-sm-8">
                    <textarea name="address" class="form-control">[[*{address}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">公司名称：</label>
                <div class="col-sm-8">
                    <input name="company" th:field="*{company}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">面积：</label>
                <div class="col-sm-8">
                    <input name="area" th:field="*{area}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">类型：</label>
                <div class="col-sm-8">
                    <select name="type" class="form-control m-b" th:with="type=${@dict.getType('custome_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{type}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">客户分类：</label>
                <div class="col-sm-8">
                    <select name="classify" class="form-control m-b" th:with="type=${@dict.getType('custome_classify')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{classify}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">标识：</label>
                <div class="col-sm-8">
                    <select name="identification" class="form-control m-b" th:with="type=${@dict.getType('custome_identification')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{identification}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">管理员标识：</label>
                <div class="col-sm-8">
                    <select name="identificationAdmin" class="form-control m-b" th:with="type=${@dict.getType('custome_identification')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{identificationAdmin}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">标注：</label>
                <div class="col-sm-8">
                    <input name="description" th:field="*{description}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">补充情况：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>
            <div class="form-group" shiro:hasAnyRoles="admin">
                <label class="col-sm-3 control-label">业务员：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="treeId" name="memberId" type="hidden" th:field="*{memberId}" />
                        <input class="form-control" type="text" onclick="selectMemberTree()" id="treeName" readonly="true" th:value="*{memberName}">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "system/customer";

        $("#form-customer-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-customer-edit').serialize());
            }
        }


        /*业务员-新增-选择父部门树*/
        function selectMemberTree() {
            var options = {
                title: '业务员选择',
                width: "800",
                url: prefix + "/selectMemberTree/" + $("#treeId").val(),
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }
        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            layer.close(index);
        }

    </script>
</body>
</html>